
    <!--用户资料-->
	<div class="tab-pane fade active in" id="tab-profile">
		<div class="panel panel-default" style="border:none;">
		    <div class="panel-body">
		  		<div class="form-horizontal">
					<div class="form-group">
						<label for="inputNick" class="col-xs-4 control-label">昵称:</label>
						<div class="col-xs-5">
							<input class="form-control" value="" name="nickname" placeholder="" type="text">
						</div>
					</div>
					<div class="form-group">
				      	<label class="col-xs-4 control-label">性别:</label>
				      	<div class="col-xs-5">
					        <div class="radio">
					            <label>
					            <input type="radio" name="sex" id="" value="1" checked="checked">
					            男
					            </label>
					        </div>
					        <div class="radio">
					            <label>
					            <input type="radio" name="sex" id="" value="0">
					            女
					            </label>
					        </div>
				      	</div>
				    </div>
					<div class="form-group">
						<label for="contact" class="col-xs-4 control-label">联系方式:</label>
						<div class="col-xs-5">
							<input class="form-control" value="" name="contact_way" placeholder="联系方式" type="text">
						</div>
					</div>
					<div class="form-group">
						<label for="email" class="col-xs-4 control-label">电子邮箱:</label>
						<div class="col-xs-5">
							<input class="form-control" value="" name="email" placeholder="电子邮箱" type="text">
						</div>
					</div>
					<div class="form-group">
				        <label for="select" class="col-xs-4 control-label">省/市/区:</label>
				        <div class="col-xs-5">
							<div class="col-xs-4 no_padding_left">
								<select class="form-control col-xs-4" name="province" id="province">
								   <option value="">请选择</option>
								 </select>
							</div>
							<div class="col-xs-4 no_padding_left">
								<select class="form-control col-xs-4" name="city" id="city">
								   <option value="">请选择</option>
								 </select>
							</div>
							<div class="col-xs-4 no_padding_left">
								<select class="form-control col-xs-4" name="area" id="area">
							       <option value="">请选择</option>
							    </select>
							</div>
							<div class="col-xs-12 no_padding_left">
							</div>
				        </div>
				    </div>
				    <div class="form-group">
						<label for="address" class="col-xs-4 control-label">详细地址:</label>
						<div class="col-xs-5">
							<input class="form-control" value="" name="address" placeholder="详细地址" type="text">
						</div>
					</div>
					<div class="form-group">
				        <label class="col-xs-4 control-label">账号状态:</label>
				        <div class="col-xs-5">
					        <div class="radio">
					          <label>
					            <input type="radio" name="state" id="normal" value="0" checked="checked">
					            正常
					            </label>
					        </div>
					        <div class="radio" >
					            <label>
					            <input type="radio" name="state" id="lock" value="1">
					            冻结
					            </label>
					        </div>
					        <div class="radio">
					            <label>
					            <input type="radio" name="state" id="title" value="2">
					            封号
					             </label>
					        </div>
				        </div>
				    </div>

				    <div class="form-group freezeTime" id="freeze" style="display:none;">
				    	<label for="email" class="col-xs-4 control-label">冻结时间(单位：秒):</label>
				    	<div class="col-xs-5">
				    		<input class="form-control" value="" name="freeze_duration" placeholder="" type="text">
				    	</div>
				    </div>
					<div class="form-group" >
				        <div class="col-xs-12 text-center">
				        	<button type="botton" id="saveBtn" class="btn btn-primary">保存修改</button>
				        </div>
				    </div>
		        	<div class="form-group" >
		          		<label for="select" class="col-xs-4 control-label no_padding_right">审核:</label>
		    	      	<div class="col-xs-5">
		    	        <select class="form-control input_size" name="validate_state">
		    	        @if($role_id == 1)
		    	          <option value="0">未认证</option>
		    	        @else
		    	          <option value="1">待审核</option>
		    	          <option value="2">审核通过</option>
		    	          <option value="3">审核未通过</option>
		    	        @endif
		    	        </select>
		    	     	</div>
    	     	        <div class="col-xs-1 text-center">
    	     	        	<button type="botton" id="audit" class="btn btn-primary">修改</button>
    	     	        </div>
		        	</div>
				</div>
		   </div>
		</div>
	</div>
    <!--用户资料-->

<script type="text/html" id="areaTemp">
<option value="-1">请选择</option>
{%each list as value}
<option value="{%value.area_id}">{%value.area_name}</option>
{%/each}
</script>
<script type="text/javascript">
// tab-base
$("#tab-profile input[name='state']").bind("click", function(){
	if($(this).val() == 1){
		$(".freezeTime").show();
	}else{
		$(".freezeTime").find("input[name='freeze_duration']").val(0);
		$(".freezeTime").hide();
	}
});

$.getq(que, url+"address/getarea", function (data){
	if(data.success){
		var html = template("areaTemp", {list :data.area});
		$("#province").html(html);
	}
})

$("#province").change(function(){
	var pid = $(this).val();
	$.getq(que, url+"address/getarea", {pid : pid}, function (data){
		if(data.success){
			var html = template("areaTemp", {list :data.area});
			$("#city").html(html);
			$("#area").html('<option value="-1">请选择</option>');
		}
	})
})

$("#city").change(function(){
	var pid = $(this).val();
	$.getq(que, url+"address/getarea", {pid : pid}, function (data){
		if(data.success){
			var html = template("areaTemp", {list :data.area});
			$("#area").html(html);
		}
	})
})

$.getq(que, url + "uc/get_user_profile", {uid : uid}, function(data){
	if(data.success){
		$("#tab-profile input[name='nickname']").val(data.data.profile.nickname);
		$("#tab-profile input[name='sex'][value='"+data.data.profile.sex+"']").attr("checked", "checked");
		$("#tab-profile input[name='contact_way']").val(data.data.profile.contact_way);
		$("#tab-profile input[name='email']").val(data.data.profile.email);
		$("#tab-profile input[name='address']").val(data.data.profile.address);
		$("#tab-profile input[name='state'][value='"+data.data.state+"']").attr("checked", "checked");
		if(data.data.profile.province){
			$("#tab-profile select[name='province']").val(data.data.profile.province);
			$.getq(que, url+"address/getarea", {pid : data.data.profile.province}, function (area){
				if(data.success){
					var html = template("areaTemp",{list: area.area})
					$("#city").html(html);
					$("#city").val(data.data.profile.city);
				}
			})
		}
		if(data.data.profile.city){
			$.getq(que, url+"address/getarea", {pid : data.data.profile.city}, function (area){
				if(data.success){
					var html = template("areaTemp",{list: area.area})
					$("#area").html(html);
					$("#area").val(data.data.profile.area);
				}
			})
		}

		$("#tab-profile input[name='freeze_duration']").val(data.data.freeze_duration);
		$("#tab-profile select[name='validate_state']").val(data.data.validate_state);
		$("#tab-profile input[name='freeze_time']").val(data.data.freeze_time);
		$("#tab-profile input[name='uid']").val(data.data.id);
		if(data.data.state == 1){
			$(".freezeTime").show();
		}
	}
});

var profileData;
$("#tab-profile #saveBtn").click(function(){
	var nickname = $("#tab-profile input[name='nickname']").val();
	var sex = $("#tab-profile input[name='sex']:checked").val();
	var contact_way = $("#tab-profile input[name='contact_way']").val();
	var email = $("#tab-profile input[name='email']").val();
	var address = $("#tab-profile input[name='address']").val();
	var province = $("#tab-profile select[name='province']").val();
	var city = $("#tab-profile select[name='city']").val();
	var area = $("#tab-profile select[name='area']").val();
	var state = $("#tab-profile input[name='state']:checked").val();
	var freeze_duration = $("#tab-profile input[name='freeze_duration']").val();
	var freeze_time = $("#tab-profile input[name='freeze_time']").val();

	$.post(url+"uc/edit_profile/update", {
		nickname : nickname,
		sex : sex,
		contact_way : contact_way,
		email : email,
		address : address,
		province : province,
		city : city,
		area : area,
		state : state,
		freeze_duration : freeze_duration,
		freeze_time : freeze_time,
		uid : uid
	}, function (data){
		if(data.success){
			success("", "修改成功");
			setTimeout(function(){
				window.location.reload();
			}, 1000)
		}
	})
})



$("#audit").click(function(){
	var validate_state = $("#tab-profile select[name='validate_state']").val();
	if(validate_state < 0 || !validate_state){
		warning("", "选择审核状态");
		return;
	}
	$.post(url + "uc/audit", {validate_state : validate_state, uid : uid}, function(data){
		if(data.success){
			success("", "修改成功");
		}
	})
})


</script>
